package com.woniuxy.goods.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.goods.mapper.GoodsMapper;
import com.woniuxy.goods.module.goods.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    GoodsMapper goodsMapper ;

    public PageInfo<Goods> findGoodsByPage(Integer now,Integer size,String name ,Integer tid){
        PageHelper.startPage(now,size);
        List<Goods> goods = goodsMapper.selectGoodsByCons(name, tid);
        return new PageInfo<>(goods);
    }

    public int add(Goods goods){
        return goodsMapper.insert(goods);
    }

    public Goods findGoodsByKey(int id) {
        return goodsMapper.selectGoodsByKey(id);
    }
}
